package com.maixy.kafkademo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName Producer
 * @Description TODO
 * @Date 2021/4/26 10:40
 * @Author maixy
 */
@RestController
public class Producer {
    @Autowired
    private KafkaTemplate kafkaTemplate;

    @GetMapping("send")
    public String send(){

        String message = "你好，我是Java旅途";
        // 第一个参数 topic
        // 第二个参数 消息
        kafkaTemplate.send("first-topic",message);
        return "ok";
    }
}
